package cn.com.dycc.sys_manage.logsysmanagement.controller;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.dycc.common.controller.BaseController;
import cn.com.dycc.sys_manage.logsysmanagement.entity.LoginCount;
import cn.com.dycc.sys_manage.logsysmanagement.entity.OperateLog;
import cn.com.dycc.sys_manage.logsysmanagement.service.LogNotFoundException;
import cn.com.dycc.sys_manage.logsysmanagement.service.OperateLogService;
import cn.com.dycc.util.JsonObjectResult;
/**
 * 
 * Description: ��־controller��
 * Author: Liket
 * Version: 1.0
 * Create Date Time: 2017��8��17�� ����11:33:15.
 * Update Date Time: 
 * @see
 */
@Controller
@RequestMapping("/log")
public class OperateLogController extends BaseController{
	@Resource
	private OperateLogService operateLogService;
	
	/*@RequestMapping("/page.do")
	@ResponseBody
	public JsonObjectResult findLog(Integer page) throws LogNotFoundException, IOException{
		List<Map<String,Object>> list = operateLogService.findLogByPage(page);
		return new JsonObjectResult(list);
	}
	
	@RequestMapping("/list.do")
	@ResponseBody
	public JsonObjectResult listLog(HttpServletRequest req) throws LogNotFoundException, IOException{
		List<Map<String,Object>> list = operateLogService.list(req);
		return new JsonObjectResult(list);
	}
	
	@RequestMapping("/param.do")
	@ResponseBody
	public JsonObjectResult findLogByParam(OperateLog log,HttpServletRequest req) throws LogNotFoundException{
//		System.out.println(log);
		List<Map<String,Object>> list = operateLogService.listLogByParam(log,req);
		return new JsonObjectResult(list);
	}
	
	@RequestMapping("/add.do")
	@ResponseBody
	public JsonObjectResult addAppLog(String logs)throws LogNotFoundException{
		System.out.println("logs="+logs);
		boolean b = operateLogService.addAppLog(logs);
		return new JsonObjectResult(b);
	}
	
	@RequestMapping("/limit.do")
	@ResponseBody
	public JsonObjectResult deleteLimit(String account,HttpServletRequest req)throws LogNotFoundException{
		boolean b = operateLogService.deleteLimit(account, req);
		return new JsonObjectResult(b);
	}
	
	@RequestMapping("/countlogin.do")
	@ResponseBody
	public JsonObjectResult countLogin(HttpServletRequest req)throws LogNotFoundException{
		LoginCount lc = operateLogService.countLogin(req);
		return new JsonObjectResult(lc);
	}*/
	
	@ExceptionHandler(LogNotFoundException.class)
	@ResponseBody
	public JsonObjectResult logExceptoin(LogNotFoundException e) {
		e.printStackTrace();
		return new JsonObjectResult(12,e);
	}	
}
